#include <cstdio>
#include <cstring>
using namespace std;

const int maxn = 25;

int queue[maxn];
int n, k, m;

int main() {
  while (scanf("%d %d %d", &n, &k, &m) == 3 && n) {
    memset(queue, 1, sizeof(queue));

    int standing = n, p = 0, q = n + 1, interval;
    while (standing) {
      interval = (k % standing ? k % standing : standing);
      while (interval--) {
        do {
          p = ((p + 1) % n) ? (p + 1) % n : n;
        } while (!queue[p]);
      }

      interval = (m % standing ? m % standing : standing);
      while (interval--) {
        do {
          q = q - 1 ? q - 1 : n;
        } while (!queue[q]);
      }
      
      if (standing < n) {
        putchar(',');
      }
      printf("%3d", p);
      if (p != q) {
        printf("%3d", q);
      }

      queue[p] = queue[q] = 0;
      standing -= (p == q) ? 1 : 2;
    }
    putchar('\n');
  }

  return 0;
}
